package com.ums.upos.service.ui;

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.ums.upos.uapi.R;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by liyang on 15-8-19.
 */
public class InstallDialog extends Dialog {
    private static final String TAG = "InstallDialog";
    private TextView textView;
    private String appName;
    private Logger log = LoggerFactory.getLogger(TAG);

    public InstallDialog(Context context) {
        super(context);
    }

    public InstallDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected InstallDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //强制屏幕常亮
        Window win = getWindow();
        win.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        //屏蔽菜单键
        win.addFlags(5);
        //屏蔽home键
        win.addFlags(3);
        //屏蔽下拉
        Settings.System.putInt(getContext().getContentResolver(), "status_bar_disabled", 1);
        setContentView(R.layout.customprogressdialog);
        textView = (TextView) this.findViewById(R.id.id_tv_loadingmsg);
        textView.setText(String.format(getContext().getResources().getString(R.string.app_being_upgraded), appName));
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
    }
}
